/**
 * Collaborative Story Development Web Application (CSDApp) Copyright Anton
 * Strack 2014
 *
 * This file is part of Collaborative Story Development Application (CSDApp).
 *
 * CSDApp is free software: you can redistribute it and/or modify it under the
 * terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or any later version.
 *
 * CSDApp is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * CSDApp. If not, see <http://www.gnu.org/licenses/>.
 *
 */
package csdwa;

import java.util.List;
import javax.servlet.http.HttpServletRequest;

/**
 * This interface is intended to act as a wrapper/adapter for and between
 * HttpServletRequest and the controller classes. It standardizes some basic
 * actions and is intended to be passed between all participating controllers in
 * the request cycle. Controller classes should use this object to interact with
 * the HttpServletRequest object.
 *
 * @author Anton Strack
 */
public interface CsdwaRequest {

    /**
     * @return the request
     */
    public HttpServletRequest getRequest();

    /**
     * @param request the request to set
     */
    public void setRequest(HttpServletRequest request);

    /**
     * @return the primaryResourceTypeName
     */
    public String getPrimaryResourceTypeName();

    /**
     * @param primaryResourceTypeName the primaryResourceTypeName to set
     */
    public void setPrimaryResourceTypeName(String primaryResourceTypeName);

    /**
     * @return the primaryResourceTypeId
     */
    public int getPrimaryResourceTypeId();

    /**
     * @param primaryResourceTypeId the primaryResourceTypeId to set
     */
    public void setPrimaryResourceTypeId(String primaryResourceTypeId);

    /**
     * @param primaryResourceTypeId the primaryResourceTypeId to set
     */
    public void setPrimaryResourceTypeId(int primaryResourceTypeId);

    /**
     * @return the primaryResourceId
     */
    public int getPrimaryResourceId();

    /**
     * @param primaryResourceId the primaryResourceId to set
     */
    public void setPrimaryResourceId(String primaryResourceId);

    /**
     * @param primaryResourceId the primaryResourceId to set
     */
    public void setPrimaryResourceId(int primaryResourceId);

    /**
     * @return the primaryActionTypeName
     */
    public String getPrimaryActionTypeName();

    /**
     * @param primaryActionTypeName the primaryActionTypeName to set
     */
    public void setPrimaryActionTypeName(String primaryActionTypeName);

    /**
     * @return the primaryActionTypeId
     */
    public int getPrimaryActionTypeId();

    /**
     * @param primaryActionTypeId the primaryActionTypeId to set
     */
    public void setPrimaryActionTypeId(String primaryActionTypeId);

    /**
     * @param primaryActionTypeId the primaryActionTypeId to set
     */
    public void setPrimaryActionTypeId(int primaryActionTypeId);

    /**
     * @return the secondaryResourceTypeName
     */
    public String getSecondaryResourceTypeName();

    /**
     * @param secondaryResourceTypeName the secondaryResourceTypeName to set
     */
    public void setSecondaryResourceTypeName(String secondaryResourceTypeName);

    /**
     * @return the secondaryResourceTypeId
     */
    public int getSecondaryResourceTypeId();

    /**
     * @param secondaryResourceTypeId the secondaryResourceTypeId to set
     */
    public void setSecondaryResourceTypeId(String secondaryResourceTypeId);

    /**
     * @param secondaryResourceTypeId the secondaryResourceTypeId to set
     */
    public void setSecondaryResourceTypeId(int secondaryResourceTypeId);

    /**
     * @return the secondaryResourceId
     */
    public int getSecondaryResourceId();

    /**
     * @param secondaryResourceId the secondaryResourceId to set
     */
    public void setSecondaryResourceId(String secondaryResourceId);

    /**
     * @param secondaryResourceId the secondaryResourceId to set
     */
    public void setSecondaryResourceId(int secondaryResourceId);

    /**
     * @return the secondaryActionTypeName
     */
    public String getSecondaryActionTypeName();

    /**
     * @param secondaryActionTypeName the secondaryActionTypeName to set
     */
    public void setSecondaryActionTypeName(String secondaryActionTypeName);

    /**
     * @return the secondaryActionTypeId
     */
    public int getSecondaryActionTypeId();

    /**
     * @param secondaryActionTypeId the secondaryActionTypeId to set
     */
    public void setSecondaryActionTypeId(String secondaryActionTypeId);

    /**
     * @param secondaryActionTypeId the secondaryActionTypeId to set
     */
    public void setSecondaryActionTypeId(int secondaryActionTypeId);

    /**
     * Get the current request type to process the request object with.
     *
     * @return the currentRequestType as either POST or GET
     */
    public String getMethod();

    /**
     * Set the current request type that the request object should be processed
     * as.
     *
     * @param currentRequestType the currentRequestType to set as either POST or
     * GET
     */
    public void setMethod(String currentRequestType);

    /**
     * Get a String value that maps to the parameter name stored in the request
     * object.
     *
     * @param attributeName name of the parameter to get
     * @return the parameter value if it exists or an empty string if it
     * doesn't.
     */
    public String getParameter(String parameterName);

    /**
     * Get a String value that maps to the attribute name stored in the request
     * object.
     *
     * @param attributeName name of the attribute to get
     * @return the attribute value if it exists or an empty string if it
     * doesn't.
     */
    public String getStringAttribute(String attributeName);

    /**
     * Get an integer value that maps to the attribute name stored in the
     * request object.
     *
     * @param attributeName name of the attribute to get
     * @return the attribute value
     */
    public int getIntegerAttribute(String attributeName);

    /**
     * Get an object value that maps to the attribute name stored in the request
     * object.
     *
     * @param attributeName name of the attribute to get
     * @return the attribute object if it exists or null if it doesn't.
     */
    public Object getAttribute(String attributeName);

    /**
     * Remove an object value that maps to the attribute name stored in the
     * request object.
     *
     * @param attributeName name of the attribute to remove
     */
    public void removeAttribute(String attributeName);

    /**
     * Set an attribute object for the request object.
     *
     * @param key the name of the attribute to act as a key
     * @param attribute an attribute object
     */
    public void setAttribute(String key, Object attribute);

    /**
     * Get the form id / form name from the request object.
     *
     * @return the formId if one exists using the
     */
    public String getFormId();

    /**
     * Remove the form id / name from the request object
     */
    public void removeFormId();

    /**
     * Set the form Id / name.
     *
     * @param formId the formId to set
     */
    public void setFormId(String formId);

    /**
     * Set the request view used to display the result of the request to the
     * user.
     *
     * @param target a path indicating the request view such as "/index.jsp"
     */
    public void setView(String target);

    /**
     * Get the request view used to display the request result to the user
     *
     * @return the request view or the default web view if none is set
     */
    public String getView();

    /**
     * Sets the result message for the request.
     *
     * @param msg the message to display on the request view for the user.
     */
    public void setMessage(String msg);

    /**
     * Gets the result message for for the request
     *
     * @return the result message if one exists or null
     */
    public String getMessage();

    /**
     * Sets the type of result message. This in intended to help instruct the
     * view how to display the result message
     *
     * @param msgType names of the type of message such as success, forbidden,
     * error, default
     */
    public void setMessageType(String msgType);

    /**
     * Gets the type of result message. This in intended to help instruct the
     * view how to display the result message
     *
     * @return msgType name of the type of message such as success, forbidden,
     * error, default
     */
    public String getMessageType();

    /**
     * Get an object value that maps to the attribute name stored in the request
     * session object.
     *
     * @param attributeName name of the attribute to get
     * @return the attribute object if it exists or null if it doesn't.
     */
    public Object getSessionAttribute(String attributeName);

    /**
     * Remove an object value that maps to the attribute name stored in the
     * request session object.
     *
     * @param attributeName name of the attribute to remove from the session
     */
    public void removeSessionAttribute(String attributeName);

    /**
     * Set an attribute object for the request session object.
     *
     * @param key the name of the attribute to act as a key
     * @param attribute an attribute object
     */
    public void setSessionAttribute(String key, Object attribute);

    /**
     * get the action from the referer url query
     *
     * @return the action if it is found or an empty string if not
     */
    public String getRefererAction();

    /**
     * get the resource from the referer url query
     *
     * @return the resource if it is found or an empty string if not
     */
    public String getRefererResource();

    /**
     * get the id from the referer url query
     *
     * @return the id if it is found or an empty string if not
     */
    public String getRefererId();

    /**
     * get the secondary resource from the referer url query
     *
     * @return the resource if it is found or an empty string if not
     */
    public String getRefererSecondaryResource();

    /**
     * Get the current user from the session.
     *
     * @return the current user stored in the request session. If one doesn't
     * exist then return a "Guest" user
     */
    public User getCurrentUser();

    /**
     * This method provides a standardized manner of setting the primary bean
     * that should be sent to the jsp. It is a wrapper removing the need for the
     * calling code to know the attribute name.
     *
     * @param bean the bean to set as the primary bean
     */
    public void setBean(Object bean);

    /**
     * this method returns the primary bean.
     *
     * @return the primary bean if it exists or null if not
     */
    public Object getBean();

    /**
     * This method provides a standardized manner of setting the primary bean
     * list that should be sent to the jsp. It is a wrapper removing the need
     * for the calling code to know the attribute name.
     *
     * @param beans the list of beans to set as the primary bean list
     */
    public void setBeans(Object beans);

    /**
     * This method returns the primary list of beans. The calling code still
     * needs to cast to the proper bean list.
     *
     * @return the primary bean list if it exists or null if not.
     */
    public Object getBeans();

    /**
     * This method returns a list of values for a parameter by converting the
     * String[] array from getParameterValues() to a List of Strings.
     *
     * @param parameterName the name of the parameter to retrieve the values
     * from.
     * @return a list of string values.
     */
    public List<String> getParameters(String parameterName);

    /**
     * This method set's the request type for processing by internal code.
     *
     * @param rtype is ASYNC for AJAX requests and SYNC for default requests.
     */
    public void setRequestType(RequestType rtype);

    /**
     * This method gets the current request type of the request.
     *
     * @return RequestType Enum of the current request.
     */
    public RequestType getRequestType();

}
